package gateway.config;

import org.springframework.cloud.gateway.route.RouteLocator;
import org.springframework.cloud.gateway.route.builder.RouteLocatorBuilder;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author:RenPu
 * @Date: 2020/7/1 16:24
 * @Version: 1.0
 * @description: 网关路由可分为二种：1：yml配置，2：编码实现，当前就为编码实现
 */

@Configuration
public class gateWayConfig {

    @Bean
    public RouteLocator getRouteLocatorBuilder(RouteLocatorBuilder routeLocatorBuilder){

        RouteLocatorBuilder.Builder routes = routeLocatorBuilder.routes();
        routes.route("test_baidu",r-> r.path("/guonei").uri("http://news.baidu.com/guonei"));

        return routes.build();

    }
}
